package com.cloudream.toucheventdemo.viewgroup;

import android.content.Context;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.MotionEvent;
import android.widget.LinearLayout;

import com.cloudream.toucheventdemo.utils.EventUtils;

import static com.cloudream.toucheventdemo.utils.EventUtils.getEvent;

/**
 * Created by Administrator on 2019/8/20.
 */

public class EventViewGroup extends LinearLayout {

    public static final String TAG = "EventViewGroup";

    public EventViewGroup(Context context) {
        super(context);
    }

    public EventViewGroup(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public EventViewGroup(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Log.i(TAG, "::dispatchTouchEvent" + getEvent(ev));
        boolean dispatchTouchEvent = super.dispatchTouchEvent(ev);
        Log.i(TAG,":: dispatchTouchEvent ::"+ EventUtils.getEvent(ev)+"result:"+dispatchTouchEvent);
        return dispatchTouchEvent;
    }



    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        Log.i(TAG, "::onInterceptTouchEvent" + getEvent(ev));
        boolean intercept =  super.onInterceptTouchEvent(ev);


        if(ev.getAction() == MotionEvent.ACTION_MOVE){
            intercept =  true;
        }
        Log.e(TAG, "::onInterceptTouchEvent" + getEvent(ev)+"result:"+intercept);
        return intercept;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.i(TAG, "::onTouchEvent" + getEvent(event));
        boolean onTouchEvent =  super.onTouchEvent(event);
        Log.i(TAG, "::onTouchEvent" + getEvent(event)+"result:"+onTouchEvent);

        return onTouchEvent;
    }




}
